﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;
using System.ServiceModel;
using System.Collections.ObjectModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;

namespace YasharEl.Infrastructure.ServiceModel.Hosting.SelfHosting
{
    public class AutoSelfHostingBehavior : IServiceBehavior
    {
        #region Private Fields

        private readonly bool _enableSelfHosting = false;

        #endregion

        #region Properties

        public bool SelfHostingEnabled
        {
            get { return _enableSelfHosting; }
        }

        #endregion

        #region Constructors

        public AutoSelfHostingBehavior(bool enableSelfHosting)
        {
            _enableSelfHosting = enableSelfHosting;
        }

        #endregion

        #region IServiceBehavior Members

        public void AddBindingParameters(ServiceDescription serviceDescription, 
            ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
        {
        }

        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
            {
                ChannelDispatcher channelDispatcher = channelDispatcherBase as ChannelDispatcher;
                if (channelDispatcher != null)
                {
                }
            }
        }

        public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
        }

        #endregion
    }
}
